#include "DebugTools.h"

#include <iostream>
#include <sstream>

#include <NxMat33.h>
#include <NxMat34.h>
#include <NxVec3.h>

//#include "Nx.h"
//#include "NxPhysics.h"

#include "../../base.h"

namespace PhysX {

/*
	DebugTools
*/

/*	public	*/

void DebugTools::output(const NxVec3& vec3) {
	std::cerr << "NxVec3  " << _output(vec3) << "\n";
}

void DebugTools::output(const NxMat33& mat33) {
	std::cerr << "NxMat33 " << _output(mat33.getRow(0)) << "\n";
	std::cerr << "NxMat33 " << _output(mat33.getRow(1)) << "\n";
	std::cerr << "NxMat33 " << _output(mat33.getRow(2)) << "\n";
}

void DebugTools::output(const NxMat34& mat34) {
	std::cerr << "NxMat34 " << "M\t" <<  _output(mat34.M.getRow(0)) << "\n";
	std::cerr << "NxMat34 " << "M\t" <<  _output(mat34.M.getRow(1)) << "\n";
	std::cerr << "NxMat34 " << "M\t" <<  _output(mat34.M.getRow(2)) << "\n";
	std::cerr << "NxMat34 " << "t\t" <<  _output(mat34.t) << "\n";
}

/*	private	*/

std::string _floatToString(float f, uint size) {
	std::ostringstream oss;
	oss << f;
	std::string s = oss.str();
	if (s.size() > size) {
		//FIX shorten
	} else if (s.size() < size) {
		for(uint i = 0; i < (size - s.size()); ++i) {
			oss << ' ';
		}
	}

	return oss.str();
}

std::string DebugTools::_output(const NxVec3& vec3) {
	std::ostringstream s;
	s << _floatToString(vec3.x, 14) << _floatToString(vec3.y, 14) << _floatToString(vec3.z, 14);
//	s << vec3.x << " \t\t" << vec3.y << " \t\t" << vec3.z;
//	std::string s;
//	sprintf(s, "%f \t%f \t%f", vec3.x, vec3.y, vec3.z);
	return s.str();
}

} // PhysX

